package com.shop.controller;


import com.shop.annotation.RequireRoles;
import com.shop.entity.SupplierSupplier;
import com.shop.model.PageParam;
import com.shop.model.vo.Rsp;
import com.shop.service.SupplierSupplierService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 供应商  yyt(SupplierSupplier)表控制层
 *
 * @author makejava
 * @since 2020-11-21 10:12:55
 */
@Validated
@RestController
@AllArgsConstructor
public class SupplierSupplierController {
    /**
     * 服务对象
     */
    @Autowired
    private final SupplierSupplierService supplierSupplierService;

    /**
     * 分页条件 查询
     */
    @RequireRoles(roles = "platform")
    @PostMapping("searchSupplierPage")
    public Rsp searchSupplierPage(@RequestBody PageParam<SupplierSupplier> pageParam) {
        return Rsp.success(supplierSupplierService.searchSupplierPage(pageParam));
    }

    /**
     * 增
     */
    //@RequireRoles(roles = "platform")
    @PostMapping("insertOne")
    public Rsp insertOne(@RequestBody SupplierSupplier supplierSupplier) {
        System.out.println(supplierSupplier.toString());
        return supplierSupplierService.insertOne(supplierSupplier);
    }

    /**
     * 改
     */
    @RequireRoles(roles = "platform")
    @PostMapping("updateOne")
    public Rsp updateOne(@RequestBody SupplierSupplier supplierSupplier) {
        return supplierSupplierService.updateOne(supplierSupplier);
    }

    /**
     * 删
     */
    @RequireRoles(roles = "platform")
    @PostMapping("deleteOne")
    public Rsp deleteOne(@RequestBody SupplierSupplier supplierSupplier) {
        return supplierSupplierService.deleteOne(supplierSupplier);
    }

    /**
     * 获取所有供应商列表
     */
    @PostMapping("getSupplierList")
    public Rsp getSupplierList(){
        return supplierSupplierService.getSupplierList();
    }


}
